package com.ftg.learn.sm.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ftg.learn.sm.pojo.Book;
import com.ftg.learn.sm.service.BookService;



@RestController
@CrossOrigin
@RequestMapping("/book")
public class BookController {
	
	


	@Autowired
	BookService bookService;
	
	@GetMapping("/showall")
	public List<Book> showAll(){
		return bookService.showAll();
	}
	
	@PutMapping("/findone/{bno}")
	public List<Book> findone(@PathVariable("bno") String bno){
		return bookService.findone(bno);
	}
	
	@PostMapping("/update")
	public int update(Book book) {
		return bookService.update(book);
	}
	
	@DeleteMapping("/delete/{bno}")
	public int delete(@PathVariable("bno") String bno) {
		return bookService.delete(bno);
	}
	
	@PostMapping("/save")
	public int save(Book book) {
		return bookService.save(book);
	}
	
}